/**
 *
 * @author 
 *
 */
class SceneObject extends egret.Sprite{
    
    private mIndex: number = 0;
    private nextFrame: number = 0;
    
	public constructor() {
    	super();
    	
    	this.init();
	}

    private img: egret.Bitmap;
    
    public init()
    {
        this.img = new egret.Bitmap();
        this.addChild(this.img);
        this.img.addEventListener(egret.Event.ENTER_FRAME, this.enterFrame, this);
        
        RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onGroupComplete, this);
        RES.loadConfig("resource/resource.json", "resource/");
    }
    
    private onGroupComplete():void
	{

	}
	
	public setStyle(newstyle:string):void
	{
        RES.loadGroup("player");
	}
	
    private mDir: number = 4;
	
    public setDir(value:number):void
    {
        this.mDir = value;
    }
	
	private static ptDic:Object = new Object;
	
    public enterFrame():void
    {
        if(this.nextFrame++ < 2) return;
        this.nextFrame = 0;

        this.mIndex++;
        if(this.mIndex > 8) this.mIndex = 1;
        var txtr: egret.Texture = RES.getRes("player.run" + (this.mIndex + this.mDir * 8));
        if(txtr == null) return;
        this.img.x = -txtr._offsetX * 2;
        this.img.y = -txtr._offsetY * 2;
        
        this.img.texture = txtr;
    }
}
